import { ref, type Ref } from 'vue'
const storageKey = 'nk-latest-id'

const latestWalletId = ref()
export function getLatestWalletId(): Ref<string> {
  latestWalletId.value = typeof localStorage !== 'undefined' ? localStorage.getItem(storageKey) || '' : ''
  return latestWalletId
}

export function addLatestWalletId(walletId: string): void {
  latestWalletId.value = walletId
  localStorage.setItem(storageKey, walletId)
}

export function clearLatestWalletId(): void {
  latestWalletId.value = undefined
  localStorage.removeItem(storageKey)
}
